<%-- Copyright (c) 2002 BroadVision, Inc. All rights reserved              --%>
<%-- The product described in this manual may be protected by one or more  --%>
<%-- U.S. and International patents. The BroadVision One-To-One software   --%>
<%-- is covered by U.S. patent 5,710,887.                                  --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and the BroadVision logo are registered       --%>
<%-- trademarks, and BroadVision One-To-One is a trademark of BroadVision, --%>
<%-- Inc. IONA and Orbix are trademarks of IONA Technologies, Ltd. RSA,    --%>
<%-- MD5, and RC2 are trademarks of RSA Data Security, Inc. All other      --%>
<%-- trademarks, service marks, and trade names belong to their respective --%>
<%-- owners. BroadVision, Inc. disclaims any proprietary interest in the   --%>
<%-- marks and names of others.                                            --%>
<%--                                                                       --%>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%-- ---------------------------------------------------------------------  
     Required information:                                                  
     1. breadcrumbs: required(java.util.List instance), breadcrumbs list. 
        It can be in any scope. The breadcrumbs list should not contain the
        virtual root. Its first element is the top category of the category
        tree, and the last element is the deepest category of the category
        tree. It should be a list of DynaAction form bean which has the 
        following attributes:
        i. oid: Oid of the category.
        ii. name: category name
     2. lastNeedLink: required, Boolean. It means whether to show last element in the
        breadcrumb as a link or as a label.
     ---------------------------------------------------------------------  --%>

<c:set var="breadcrumbRootLink">
  <c:url var="rootBrowseUrl" value="/em/segment/segmentBrowse.do">
    <c:param name="currentCategoryOid" value="0"/>
  </c:url>
  <a href='<c:out value="${rootBrowseUrl}" escapeXml="false" />'><bean-el:message bundle="em" key="em.category.root" /></a>
</c:set>

<c:set var="breadcrumbCategorySeparator">
  &nbsp;<bean-el:message bundle="em" key="em.category.separator" />&nbsp;
</c:set>

<div class="breadcrumb">
  <c:choose>
    <c:when test="${not empty breadcrumbs}">
      <bean-el:size id="breadcrumbsSize" name="breadcrumbs" />
      <c:out value="${breadcrumbRootLink}" escapeXml="false" />
      <c:forEach var="category" items="${breadcrumbs}" varStatus="index">
        <c:url var="browseUrl" value="/em/segment/segmentBrowse.do">
          <c:param name="currentCategoryOid" value="${category.map.oid}"/>
        </c:url>
        <c:out value="${breadcrumbCategorySeparator}" escapeXml="false" />
        <c:choose>
          <c:when test="${index.count == breadcrumbsSize}">
            <%-- This is the last one. --%>
            <c:choose>
              <c:when test="${lastNeedLink}">
                <a href="<c:out value="${browseUrl}"/>"><c:out value="${category.map.name}"/></a>
              </c:when>
              <c:otherwise>
                <c:out value="${category.map.name}"/>
              </c:otherwise>
            </c:choose>
          </c:when>
          <c:otherwise>
            <a href="<c:out value="${browseUrl}"/>"><c:out value="${category.map.name}"/></a>
          </c:otherwise>
        </c:choose>
      </c:forEach>
    </c:when>
    <c:otherwise>
      <c:choose>
        <c:when test="${lastNeedLink}">
          <c:out value="${breadcrumbRootLink}" escapeXml="false" />
        </c:when>
        <c:otherwise>
          <bean-el:message bundle="em" key="em.category.root"/>
        </c:otherwise>
      </c:choose>
    </c:otherwise>
  </c:choose>
</div>